package cn.iocoder.yudao.module.product.enums.spu;

import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 配送方式
 *
 * @author lizhongwen
 */
@Getter
@AllArgsConstructor
public enum DeliveryTypeEnum implements IntArrayValuable {
    EXPRESS_DELIVERY(1, "快递发货"),
    CUSTOMER_PICKUP(2, "用户自提"),
    NO_DELIVERY_NEEDED(3, "无需配送");

    /**
     * 值
     */
    private final int value;

    /**
     * 描述
     */
    private final String desc;

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DeliveryTypeEnum::getValue).toArray();

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public DeliveryTypeEnum fromValue(int value) {
        for (DeliveryTypeEnum item : values()) {
            if (item.value == value) {
                return item;
            }
        }
        throw new IllegalArgumentException("枚举类型 DeliveryTypeEnum 不支持整型值：" + value);
    }
}
